package com.example.myfirstapp2;

import java.util.Vector;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyListAdapter extends BaseAdapter {

	Vector<BuyerOrder> m_list = null;

	public MyListAdapter(Vector<BuyerOrder> orders) {
		m_list = orders;
	}

	@Override
	public int getCount() {

		return m_list.size();
	}

	@Override
	public Object getItem(int arg0) {

		return m_list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {

		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.order_list_view_item, null);
		} 
		ImageView iv = (ImageView) convertView.findViewById(R.id.imageView1);
		
		iv.setImageBitmap(m_list.get(position).itemImage);
		
		TextView tv1 = (TextView) convertView.findViewById(R.id.textView1);
		
		tv1.setText(m_list.get(position).InfoToString());
		
		TextView tv2 = (TextView) convertView.findViewById(R.id.textView2);
		
		tv2.setText(m_list.get(position).itemName);
		
		convertView.setTag(m_list.get(position));
		
		return convertView;
	}

}
